package com.example.smart_city_0829.activity.sdkm;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.smart_city_0829.DeathData;
import com.example.smart_city_0829.R;
import com.example.smart_city_0829.base.BaseActivity;
import com.example.smart_city_0829.entity.sdkm.Activities;
import com.example.smart_city_0829.entity.sdkm.Content;
import com.example.smart_city_0829.entity.sdkm.Kmlb;

public class AddContentActivity extends BaseActivity {

    private EditText title;
    private EditText content;
    private Button ok;
    private EditText name;




    @Override
    protected int getLayoutId() {
        return R.layout.activity_add_content;
    }

    @Override
    protected void initView() {
        title = (EditText) findViewById(R.id.title);
        content = (EditText) findViewById(R.id.content);
        ok = (Button) findViewById(R.id.ok);
        name = (EditText) findViewById(R.id.name);

        name.setVisibility(View.GONE);
    }

    @Override
    protected void initData() {
        if (getIntent().getIntExtra("type",0) == 3) {
            name.setVisibility(View.VISIBLE);
        }
    }

    @Override
    protected void initEvent() {
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (getIntent().getIntExtra("type",0)){
                    case 0:
                        DeathData.xxgy.add(new Content(
                                title.getText().toString(),
                                content.getText().toString()
                        ));
                        break;
                    case 1:
                        DeathData.xxbj.add(new Content(
                                title.getText().toString(),
                                content.getText().toString()
                        ));
                        break;
                    case 2:
                        DeathData.activities.add(
                                new Activities(title.getText().toString(),
                                        0,
                                        content.getText().toString(),
                                        "我自己")
                        );
                        break;
                    case 3:
                        DeathData.sbdyx.add(new Kmlb(
                                0,
                                "",
                                0,
                                title.getText().toString(),
                                content.getText().toString()
                        ));
                }
                AddContentActivity.this.finish();
            }
        });
    }

    @Override
    protected String getActionBarTitle() {
        return "添加";
    }
}